ransomNote = "aa", magazine = "aab"
var canConstruct = function(ransomNote, magazine) {
    let obj = {}
    for(let i=0;i<magazine.length;i++){
        if(obj[magazine[i]]){
            obj[magazine[i]] = obj[magazine[i]] + 1
        }else{
            obj[magazine[i]] = 1
        }
    }
    for(let j=0;j<ransomNote.length;j++){
        if(obj.hasOwnProperty(ransomNote[j])){
            obj[ransomNote[j]] = obj[ransomNote[j]] - 1
            if(obj[ransomNote[j]]<0){
                return false
            }
        }else{
            return false
        }
    }
    return true
};
console.log(canConstruct(ransomNote,magazine));
